function checkEmail(){
    var emailInput=document.getElementById('email')
    emailInput.onblur=function(){
        var checkrule=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
        var emailprompt=document.getElementById('email_prompt')
        console.log(checkrule.test(emailInput.value))
        if(checkrule.test(emailInput.value)){
            emailprompt.className='regok'
        }else{
            emailprompt.className=''
        }
    }
}

function checkName(){
    var nameInput=document.getElementById('nickName')
    nameInput.onblur=function(){
        var checkrule1=/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{4,20}$/
        var nickName=document.getElementById('nickName_prompt')
        var newdiv=document.createElement('div')
        nickName.parentNode.append(newdiv)
        newdiv.innerHTML= '<div id="ND" style="border:1px solid #ccc;width: 340px;color: #f00;background-color: rgb(255,245,225);display:none;">'+'昵称格式错误，请用大小写英文字母、数字，长度为4-20个字符'+'</div>'
        var ND=document.getElementById('ND')
        console.log(checkrule1.test(nameInput.value))
        if(checkrule1.test(nameInput.value)){
            nickName.className='regok'
            ND.style.display='none'
        }else{
            nickName.className='' 
            ND.style.display='block'
        }
    }
}
function checkPwd(){
    var pwd=document.getElementById('pwd')
    var pwdprompt=document.getElementById('pwd_prompt')
    pwd.onfocus=function(){
        pwdprompt.innerText='密码可由大小写英文字母、数字组成，长度6-20个字符'
    }
    pwd.onblur=function(){
        pwdprompt.innerText=''
    }

}
function checkRepwd(){
    var password=document.getElementById('pwd').value
    var repassword=document.getElementById('repwd').value
    if(password == repassword ){
        document.getElementById('repwd_prompt').innerText=''
    }else{
        document.getElementById('repwd_prompt').innerText="两次输入密码不一致!"
    }
}

